package com.keepers.repair.utils

import android.content.Context
import com.keepers.repair.model.ServerModel
import com.keepers.repair.model.UserModel
import org.jetbrains.anko.defaultSharedPreferences

fun getUser(context: Context): UserModel? {
    return context.defaultSharedPreferences.getObject<UserModel>("user", null)
}

fun setUser(context: Context, user: UserModel?) {
    val edit = context.defaultSharedPreferences.edit()
    if (user != null) {
        edit.putObject("user", user)
    } else {
        edit.putString("user", null)
    }
    edit.apply()
}

/**
 * 默认的服务器设置
 */
val defaultServerConfig = ServerModel(
    host = "task.keepers.com.cn",
    port = 8089
)

object Config {

    const val httpHost = "task.keepers.com.cn"
    const val httpPort = 8089

//    const val httpUrlHead = "http://$httpHost:$httpPort/"


    const val httpUrl = "http://$httpHost:$httpPort/WebService/WebService/"
    const val voiceUrl = "http://$httpHost:$httpPort/UploadFile/ChatVoice/"

    const val socketHost = "task.keepers.com.cn"
    const val socketPort = 7000
}
